﻿using System;
using System.Collections.Generic;

using SiteUnity.Frame.Common.Tools.Class;
using SiteUnity.Layers.Entity.PageItems;

namespace SiteUnity.Layers.Entity.General
{
    [Serializable]
    public class Page
    {
        #region Constructor
        public Page()
        {
            ChildPages = new List<Page>();
        }

        public Page(Guid guid)
        {
            ChildPages = new List<Page>();
            this.Guid = guid;
        }
        #endregion

        #region Properties
        public Guid Guid { get; set; }

        public string Title { get; set; }

        public string Url
        {
            get
            {
                if (typeID == 1)
                    return "/";

                if (ParentPage != null)
                    if (ParentPage.Url == "/")
                        return "/" + Title;
                    else
                        return ParentPage.Url + "/" + Title;
                else
                    return "/" + Title;
            }
        }

        public Guid ParentGuid { get; set; }

        public int typeID { get; set; }

        public DateTime Date { get; set; }
        #endregion

        #region Additional Properties
        public virtual Page ParentPage { get; set; }

        public List<Page> ChildPages { get; set; }
        #endregion
    }
}